#include "mainwindow.h"

#include <QApplication>
#include <QLocale>
#include <QTranslator>
//#include <QFontDatabase>

#include <signinwidget.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "Link-client_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }

//    int fontId = QFontDatabase::addApplicationFont(":/img/res/font/smiley-sans-v1.1.1/SmileySans-Oblique.ttf");
//    QString PingFangSC = QFontDatabase::applicationFontFamilies(fontId).at(0);
//    QFont font(PingFangSC,10);
//    QApplication::setFont(font);

    MainWindow mainWindow;
    SignInWidget signInWidget;
    signInWidget.show();

    QObject::connect(&signInWidget, SIGNAL(signal_signInSuccess(QJsonObject)), &mainWindow, SLOT(slot_signInSuccess(QJsonObject)));
    QObject::connect(&mainWindow, SIGNAL(signal_signOut()), &signInWidget, SLOT(show()));

    return a.exec();
}
